package com.yidianyanglao.shop.mapper;

import com.yidianyanglao.shop.bean.Shop;
import com.yidianyanglao.userData.bean.ShopBean;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by lf on 2016/11/03.
 */
@Repository
public interface ShopMapper {

    /**
     * 获取shop列表
     * @param begin
     * @param shopname
     * @return
     */
    @Select("SELECT * from yl_shop where shopname like concat(concat('%',#{shopname}),'%') and province=#{province} and city=#{city} and area like concat(concat('%',#{area}),'%') and shopstate=0 order by createtime desc limit #{begin},10")
    List<ShopBean> getShopList(@Param("begin") int begin, @Param("shopname") String shopname, @Param("province") String province,@Param("city") String city,@Param("area") String area);

    /**
     * 获取shop列表
     * @param begin
     * @param shopname
     * @return
     */
    @Select("SELECT * from yl_shop where shopname like concat(concat('%',#{shopname}),'%') and province=#{province} and city=#{city} and area like concat(concat('%',#{area}),'%') and shopstate=0 and industry_type = #{industrytype} order by createtime desc limit #{begin},10")
    List<ShopBean> getShopListByIndustry(@Param("begin") int begin, @Param("shopname") String shopname, @Param("province") String province,@Param("city") String city,@Param("area") String area,@Param("industrytype")String industrytype);

    /**
     * 获取商户详情
     * @param id
     * @return
     */
    @Select("SELECT * FROM yl_shop WHERE id = #{id}")
    Shop getShopById(@Param("id") int id);

}
